﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tosi
{
    class LightControls
    {
        private double [] Controls;
        public Light myLight;
        private double waitingCars;
        private double waitingTime;
        private double streetLoad;

        public LightControls()
        {
            waitingCars = 0;
            waitingTime = 0;
            streetLoad = 0;
            Controls = new double[6];
            for (int i = 0; i < 6; i++)
                Controls[i] = 0;
        }
        public void setMyLight(Light L)
        {
            myLight = L;
        }
        public void countWaitingCars(double x)
        {
            waitingCars += 100 * Math.Exp(-5*x/myLight.myStreet.getMaxCars());
        }
        public void countWaitingTime(double x)
        {
            waitingTime += 100 * Math.Exp(-5*x/Var.Iterations);
        }
        public void countStreetLoad(double x)
        {
            streetLoad += 100 * Math.Exp(-5*x/100);
        }
        public double getWaitingCars()
        {
            return waitingCars;
        }
        public double getWaitingTime()
        {
            return waitingTime;
        }
        public double getStreetLoad()
        {
            return streetLoad;
        }
        public void allTOSI()
        {
            waitingCars /= Var.Intervals;
            waitingTime /= Var.Intervals;
            streetLoad /= Var.Intervals;
        }
        //public LightControls(ref LightControls LC)
        //{
        //    myLight = LC.myLight;
        //    Controls = new double[6];
        //    for (int i = 0; i < 6; i++)
        //        Controls[i] = LC.Controls[i];
        //}

        public void setLightControls(double [] C)
        {
            for (int i = 0; i < 6; i++)
                Controls[i] = C[i];
            myLight.initWeights(Controls);
        }
        public double[] getLightControls()
        {
            return Controls;
        }
    }
}
